<script setup lang="ts">
import resetUser from './reset-user.vue'
import resetPwd from './reset-pwd.vue'
import dayjs from 'dayjs'
import userAvatar from './user-avatar.vue'
import { useProfile } from './hook'
defineOptions({
  name: 'Profile',
})

const { user, activeTab, postGroup, roleGroup } = useProfile()
</script>

<template>
  <div class="main table-view-layout">
    <el-row :gutter="20">
      <el-col :span="8" :xs="24">
        <el-card shadow="never">
          <template v-slot:header>
            <div class="clearfix">
              <span>个人信息</span>
            </div>
          </template>
          <div v-if="false" class="text-center">
            <userAvatar :user="user" />
          </div>
          <el-descriptions direction="vertical" :column="1" border>
            <el-descriptions-item label="用户名称">{{ user.userName }}</el-descriptions-item>
            <el-descriptions-item label="手机号码">{{ user.phonenumber }}</el-descriptions-item>
            <el-descriptions-item label="用户邮箱">{{ user.email }}</el-descriptions-item>
            <el-descriptions-item label="所属部门">
              {{ user.dept?.deptName }} / {{ postGroup }}
            </el-descriptions-item>
            <el-descriptions-item label="所属角色">
              <el-tag size="small">{{ roleGroup }}</el-tag>
            </el-descriptions-item>
            <el-descriptions-item label="创建日期"
              >{{ dayjs(user.createTime) }}
            </el-descriptions-item>
          </el-descriptions>
        </el-card>
      </el-col>
      <el-col :span="16" :xs="24">
        <el-card shadow="never">
          <template v-slot:header>
            <div class="clearfix">
              <span>基本资料</span>
            </div>
          </template>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="userinfo">
              <resetUser :user="user" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <resetPwd />
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
